<?php 
namespace Home\Controller;
use Think\Controller;
class ServiceController extends CommonController{
	public function index(){
		$this->display();
	}

	public function verify(){
		import('ORG.Util.Image');
		Image::buildImageVerify();
	}

	public function check(){
		$user=M('User');
		if(md5($_POST[fcode])==$_SESSION['verify']){
			$_POST['password']=($_POST[password]);
			if($rst=$user->where($_POST)->find()){
				$_SESSION['login']=1;
				$_SESSION['username']=$_POST['username'];
				$_SESSION['admin']=$rst['admin'];
				if($rst['admin']){
					$this->success('登录成功',U('Index/index'));
				}else{
					$this->error('您的权限不足!',U('index'));
				}
			}else{
				$this->error('用户名或密码有误',U('index'));
			}
		}else{
			$this->error('验证码有误码!');
		}
	}

	public function logout(){
		setcookie(session_name(),'',time()-3600,'/');
		session_unset();
		session_destroy();

		$this->success('退出成功',U('index'));
	}
}
 ?>